#ifndef POINT_H__
#define POINT_H__

#include "Vector.h"

class SPoint
{
public:
	static SPoint UNKNOWN;

	SPoint(void);
	SPoint(const float _x, const float _y, const float _z);
	SPoint(const SPoint& copy);
	~SPoint();

	inline Vector operator-(const SPoint& p) const
	{
		return Vector(x - p.x, y - p.y, z - p.z);
	}
	inline SPoint operator+(const Vector& v) const
	{
		return SPoint(x + v.x, y + v.y, z + v.z);
	}
	inline SPoint operator-(const Vector& v) const
	{
		return SPoint(x - v.x, y - v.y, z - v.z);
	}
	inline SPoint operator*(float m) const
	{
		return SPoint(x * m, y * m, z * m);
	}

	inline SPoint& operator+=(const Vector& v)
	{
		x += v.x;
		y += v.y;
		z += v.z;
		return *this;
	}
	inline SPoint& operator-=(const Vector& v)
	{
		x -= v.x;
		y -= v.y;
		z -= v.z;
		return *this;
	}
	inline SPoint& operator/=(float m)
	{
		x /= m;
		y /= m;
		z /= m;
		return *this;
	}
	inline SPoint& operator*=(float m)
	{
		x *= m;
		y *= m;
		z *= m;
		return *this;
	}

	inline bool operator==(const SPoint& p) const
	{
		if (x == p.x && y == p.y && z == p.z)
			return true;
		return false;
	}

	inline bool operator!=(const SPoint& p) const
	{
		if (x == p.x && y == p.y && z == p.z)
			return false;
		return true;
	}
	
	inline float get(const int axis) const
	{
		return *((&x) + axis);
	}
	
	/**
	 * rotates the point around a given angle by "a" radians
	 * @param v the vector
	 * @param a the angle in radians
	 */
	void rotateAround(const Vector& v, float a);
	
	friend std::ostream& operator<<(std::ostream& ostr, const SPoint& v);

	/**
	 * checks if two lines intersect
	 * returns the point of intersection if they do,
	 * otherwise an exception is thrown
	 */
	//	static SPoint intersect(const SPoint& p1b, const SPoint& p1e,
	//			const SPoint& p2b, const SPoint& p2e) throw (std::out_of_range);

	float x;
	float y;
	float z;
protected:
private:
};

#endif // POINT_H
